function _ctUuidV4() { if (window.crypto && window.crypto.randomUUID) { try { return window.crypto.randomUUID(); } catch (e) {} } var buf = new Uint8Array(16); if (window.crypto && window.crypto.getRandomValues) { window.crypto.getRandomValues(buf); } else { for (var i = 0; i < 16; i++) buf[i] = Math.floor(Math.random() * 256); } buf[6] = (buf[6] & 0x0f) | 0x40; buf[8] = (buf[8] & 0x3f) | 0x80; var hex = []; for (var j = 0; j < 16; j++) { var s = buf[j].toString(16); if (s.length < 2) s = '0' + s; hex.push(s); } return hex[0]+hex[1]+hex[2]+hex[3] + '-' + hex[4]+hex[5] + '-' + hex[6]+hex[7] + '-' + hex[8]+hex[9] + '-' + hex[10]+hex[11]+hex[12]+hex[13]+hex[14]+hex[15]; } function convert(input) { var raw = (input || '').trim(); var n = parseInt(raw, 10); if (!isFinite(n) || n < 1) n = 1; n = Math.min(n, 1000); var out = []; for (var i = 0; i < n; i++) out.push(_ctUuidV4()); return out.join('\n'); } $(function(){ setTimeout(function(){ var box1 = document.getElementById('box1'); var box2 = document.getElementById('box2'); if (box1 && box2 && !box1.value && !box2.value) { box2.value = _ctUuidV4(); } }, 50); }); var _loadedScripts = {}; function loadScriptPromise(url) { if (_loadedScripts[url]) return _loadedScripts[url]; _loadedScripts[url] = new Promise(function (resolve, reject) { var s = document.createElement('script'); s.src = url; s.onload = resolve; s.onerror = reject; document.head.appendChild(s); }); return _loadedScripts[url]; } function replaceAll(find, replace, str) { return str.replace(new RegExp(find, 'g'), replace); } function beautify(str) { var result = ''; var length = str.length; var i = 0; var braceCountLeft = 0; var braceCountRight = 0; var withinQuotes = false; while (i < length) { var c = str[i]; if (c == '"' && (i == 0 || c[i - 1] != '\\')) { // non-escaped quotes withinQuotes = !withinQuotes; } if (!withinQuotes && (c == '}' || c == '{' || c == ',')) { console.log('Start####' + result); // look back and remove carriage returns and whitespace that are already there var resultIndex = result.length - 1; while (resultIndex >= 0 && (result[resultIndex] == ' ' || result[resultIndex] == '\r' || result[resultIndex] == '\n' || result[resultIndex] == '\t')) { resultIndex = resultIndex - 1; result = result.substr(0, resultIndex + 1); console.log('char ' + result[resultIndex] + '-----' + result + 'zzz ' + result.length + ' ' + resultIndex); } if (c == '{') { braceCountLeft++; result += c + '\r' + GetTabs(braceCountLeft - braceCountRight); } else if (c == '}') { braceCountRight++; // precede with carriage return result += '\r' + GetTabs(braceCountLeft - braceCountRight) + c; } else if (c == ',') { result += c + '\r' + GetTabs(braceCountLeft - braceCountRight); } var nextChar = ''; // advance through whitespace and remove carriage returns that are already there while (i < length && (str[i + 1] == ' ' || str[i + 1] == '\r' || str[i + 1] == '\n' || str[i + 1] == '\t')) { i++; } } else { result += str[i]; } i++; } return result; } function GetTabs(count) { var result = ''; for (var i = 0; i < count; i++) { result += ' '; } return result; }